package cn.edu.hqu.javae.web;

import javax.validation.Valid;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.Errors;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.edu.hqu.javae.domain.Im;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@Controller
@RequestMapping("/personal")
public class ImController {
	@GetMapping("/im")
	public String orderForm(Model model) {
		model.addAttribute("im",new Im());
		return "im";
	}
	 @PostMapping
	 public String processOrder(@Valid Im im,Errors errors) {
		 if(errors.hasErrors()) {
			 return "im";
		 }
	   log.info("Order submitted: " + im);
	   return "zs";
	 }

}
